package com.dgut.cbd.config;

import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import java.time.Duration;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

/**
 * @Program: exp3
 * @Description:
 * @Author: cbd
 * @Create: 2021-05-10
 * @Version: 1.0.0
 **/
@Configuration
public class RestTemplateConfig {

    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder) {
        return builder.setReadTimeout(Duration.ofSeconds(60))
                .setConnectTimeout(Duration.ofSeconds(60))
                .build();
    }

    @Bean
    public ReadWriteLock lockObject(){
        ReadWriteLock rwlock = new ReentrantReadWriteLock();
        return  rwlock;
    }

}
